<?php
class MenuModel extends CommonModel {
	/* 根据父级获取子级菜单信息
	 * @param pid,父级菜单
	 * 返回数组
	*/
	public function getMenuByPid($pid = 0)
	{
		//
		$where['pid'] = $pid;
		$where['status'] = 1;
		$result = $this->where($where)->field('id,pid,name,action,isfolder,isopen')->order('sort desc')->findAll();
		$data = array();
		if($result)
		{
			foreach ($result as $r)
			{
//				if ($r['action']){
//					$r['son_menu'] = 0;
//				}
//				else 
//				{
					$r['son_menu'] =  $this->getMenuByPid($r['id']);
//				}
				$data[] = $r;
			}
		}
		return $data;
	}
}
?>